package com.lou.annotation.support;

import org.springframework.core.MethodParameter;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;

import com.lou.annotation.TestMethodArgumentResolverAnnotation;
/** 
 * @author : ljl
 * @date 创建时间：2018年9月11日 下午4:57:13 
 * @version 1.0 
 * @parameter  
 * @since  
 * @return  
 */
public class TestMethodArgumentResolver implements HandlerMethodArgumentResolver {

	@Override
	public boolean supportsParameter(MethodParameter parameter) {
		System.out.println("进来咯");
		//这样的写法是针对对应的参数类去实现
//		return parameter.getParameterType().equals(TestDTO.class);
//		对应注解去实现		
		return parameter.hasParameterAnnotation(TestMethodArgumentResolverAnnotation.class);	
	}

	@Override
	public Object resolveArgument(MethodParameter parameter,
			ModelAndViewContainer mavContainer, NativeWebRequest webRequest,
			WebDataBinderFactory binderFactory) throws Exception {
		System.out.println("进入解析阶段");
		System.out.println(parameter);	
		System.out.println(mavContainer);
		System.out.println(webRequest);
		System.out.println(binderFactory);
		return binderFactory;		 
	}

}
